/**
 * Created with JetBrains PhpStorm.
 * User: ishowshao
 * Date: 12-8-20
 * Time: 下午12:58
 */
var array = [];
for (var x = 0; x < 20000; x++) {
    array.push(x + 1);
}
function shuffle() {
    return Math.random() - 0.5;
}
array.sort(shuffle);
array.sort(shuffle);


console.log(+new Date());
array.sort(function (a, b) {
    return a > b;
});
console.log(+new Date());

array.sort(shuffle);
array.sort(shuffle);

var start = +new Date();
for (var j = 1; j < array.length; j++) {
    var element = array[j];
    for (var i = j; i > 0; i--) {
        if (element < array[i - 1]) {
            array[i] = array[i - 1];
            array[i - 1] = element;
        } else {
            break;
        }
    }
}
console.log(+new Date() - start);
